//
//  VerifyViewController.m
//  Hxcsfw
//
//  Created by qiysoft on 2017/11/7.
//  Copyright © 2017年 企友软mac. All rights reserved.
//

#import "VerifyViewController.h"
#import "VerifyCell.h"
#import "WWebViewController.h"
#import "MQVerCodeImageView.h"
#define VerifyCellIndentifier @"VerifyCellIndentifier"
#import "RegisterViewController.h"

@interface VerifyViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    VerifyCell *cell1;
}
@property (nonatomic, strong) MQVerCodeImageView *codeImageView;

@end

@implementation VerifyViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // 1.注册控件
    UINib *cellNib = [UINib nibWithNibName:@"VerifyCell" bundle:nil];
    [self.myTableView registerNib:cellNib forCellReuseIdentifier:VerifyCellIndentifier];
    _myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.prototypeCell  = [self.myTableView dequeueReusableCellWithIdentifier:VerifyCellIndentifier];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginSuccessClick) name:@"LoginSuccess" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(VERIFYREGISTERClick) name:@"VERIFYREGISTER" object:nil];//注册通知

}

-(void)VERIFYREGISTERClick {//注册实现
    /*
    WWebViewController *webVc = [[WWebViewController alloc] init];
    webVc.strUrl = @"http://192.168.0.38:11000/sxhtjs/zstapp?params=%2FO5VEuP53%2BWqeopc9K5F1VM9cHFSt7skYkaNuWT%2BEhP0c0zbqoqL95WAP3ZQsCor";
    webVc.strTitle = @"注册";
    [self.navigationController pushViewController:webVc animated:YES];
     */
    
    RegisterViewController *loginVc = [[RegisterViewController alloc] init];
    [self.navigationController pushViewController:loginVc animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//设置UITableViewCell的数据
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    cell1 = [[[NSBundle mainBundle] loadNibNamed:@"VerifyCell" owner:self options:nil] lastObject];
    cell1.selectionStyle = UITableViewCellSelectionStyleNone;
    
    // 添加图片验证码
    _codeImageView = [[MQVerCodeImageView alloc] initWithFrame:CGRectMake(0, 0, 85, 45)];
    _codeImageView.bolck = ^(NSString *imageCodeStr){//看情况是否需要
        WLog(@"imageCodeStr = %@",imageCodeStr);
        WLog(@"转换为小写字符串:%@",[imageCodeStr lowercaseString]);
        [WShareUtil sharedData].SmallTpyzm = [imageCodeStr lowercaseString];
        //小写图片验证码存单例
    };
    _codeImageView.isRotation = NO;
    [_codeImageView freshVerCode];
    
    //点击刷新
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)];
    [_codeImageView addGestureRecognizer:tap];
    [cell1.TPYzmView addSubview:_codeImageView];
    
    return cell1;
}
// 图片验证码点击方法
- (void)tapClick:(UITapGestureRecognizer*)tap
{
    [_codeImageView freshVerCode];
}

//行点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    
}

//分组个数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

//列表行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

//设置行高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return WSCREENH_HEIGHT-72-49;
}

- (void)loginSuccessClick {
    [self.navigationController popToRootViewControllerAnimated:YES];
}

-(void)dealloc{
    //移除所有通知监控
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

@end
